import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:hm_show_flutter/page/activity/activity_detail_page.dart';
import 'package:hm_show_flutter/page/activity/activity_list_page.dart';
import 'package:hm_show_flutter/page/company/company_detail_page.dart';
import 'package:hm_show_flutter/page/company/company_list_page.dart';
import 'package:hm_show_flutter/page/goods/category_list_page.dart';
import 'package:hm_show_flutter/page/goods/collection_list_page.dart';
import 'package:hm_show_flutter/page/goods/goods_detail_page.dart';
import 'package:hm_show_flutter/page/goods/goods_list_page.dart';
import 'package:hm_show_flutter/page/goods/search_goods_page.dart';
import 'package:hm_show_flutter/page/home/main_page.dart';
import 'package:hm_show_flutter/page/login/login_page.dart';
import 'package:hm_show_flutter/page/login/register_page.dart';
import 'package:hm_show_flutter/page/mine/about_us.dart';
import 'package:hm_show_flutter/page/mine/appointment_list_page.dart';
import 'package:hm_show_flutter/page/mine/course_list_page.dart';
import 'package:hm_show_flutter/page/mine/member_list_page.dart';
import 'package:hm_show_flutter/page/setting/edit_name_page.dart';
import 'package:hm_show_flutter/page/setting/setting_page.dart';
import 'package:hm_show_flutter/page/splash/splash_page.dart';
import 'package:hm_show_flutter/utils/fluro_convert_util.dart';
import 'package:hm_show_flutter/utils/string_util.dart';
import 'package:hm_show_flutter/widgets/webview.dart';

var splashHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return SplashPage();
});

var homeHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return MainPage();
});

var loginHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return LoginPage();
});

var registerHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return RegisterPage();
});

var categoryGoodsListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<Object>> parameters) {
  var categoryName =
      StringUtils.decode(parameters["categoryName"].first).toString();
  print("categoryName" + categoryName);
  print("categoryId" + parameters["categoryId"].first);
  var categoryId = int.parse(parameters["categoryId"].first);
  var parentId = int.parse(parameters["parentId"].first);
  return CategoryListPage(categoryName, categoryId, parentId);
});

var goodsDetailsHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<Object>> parameters) {
  var goodsId = int.parse(parameters["goodsId"].first);
  return GoodsDetailPage(goodsId);
});

var goodsListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return GoodsListPage();
});

var activityListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return ActivityListPage();
});

var activityDetailsHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<Object>> parameters) {
  var id = int.parse(parameters["id"].first);
  return ActivityDetailPage(id);
});

var collectionListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return CollectionListPage();
});

var settingHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  return SettingPage();
});

var companyListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  var type = int.parse(parameters["type"].first);
  return CompanyListPage(type);
});

var companyDetailsHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<Object>> parameters) {
  var id = int.parse(parameters["id"].first);
  return CompanyDetailPage(id);
});

var webViewHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
  var title = FluroConvertUtils.fluroCnParamsDecode(parameters["title"].first);
  var url = FluroConvertUtils.fluroCnParamsDecode(parameters["url"].first);
  return WebViewPage(url, title);
});

var searchGoodsHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
      return SearchGoodsPage();
    });

var editNameHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
      return EditNamePage();
    });

var memberHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
      return MemberListPage();
    });

var courseListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
      return CourseListPage();
    });

var aboutUsHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
      return AboutUsPage();
    });

var appointmentListHandler = Handler(
    handlerFunc: (BuildContext context, Map<String, List<String>> parameters) {
      return AppointmentListPage();
    });
